<template>
  <div>
    <div class="app-container">
      <div style="background-color: white;padding: 10px 10px 10px 10px">
        <el-form @submit.native.prevent :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch"
                 label-width="68px">
          <el-form-item label="搜索：" prop="schoolName" style="margin-bottom: 0">
            <el-input
              v-model="queryParams.schoolName"
              placeholder="请输入学校名称"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div style="background-color: white;margin-top: 10px;padding: 20px">
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              endicon="el-icon-plus"
              size="mini"
              @click="closePage"
            >返回
            </el-button>
          </el-col>
        </el-row>
        <el-table v-loading="loading" :data="formList" :header-cell-style="{background:'#E3E3E3'}">
          <el-table-column label="序号" align="center">
            <template v-slot="scope">
              {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
            </template>
          </el-table-column>
          <el-table-column label="学校名称" align="center" prop="schoolName"/>
          <el-table-column label="填报日期" align="center" prop="answerDate"/>
          <el-table-column label="填报情况" align="center">
            <template v-slot="scope">
              <span v-if="scope.row.status==='1'" style="color:#07A387 ">已填</span>
              <span v-else style="color:#E94242 ">未填</span>
              <!--              <span v-if="new Date(scope.row.fillTimeLimit).getTime()<new Date(scope.row.fillTime)"-->
              <!--                    style="color:#07A387 "><span style="color: red">-->
              <!--                (超时)-->
              <!--              </span></span>-->
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template v-slot="scope">
              <el-button
                size="mini"
                type="text"
                @click="handleJump(scope.row)"
              >查看填报结果
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import {listCheck} from "@/api/patrol/check";

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 单表格数据
      formList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        checkId: null,
        pageNum: 1,
        pageSize: 10,
        schoolName: null,
      },
      checkName: ""
    };
  },
  created() {
    let checkId = JSON.parse(decodeURI(this.$route.query.checkId))
    let checkName = JSON.parse(decodeURI(this.$route.query.checkName))
    this.queryParams.checkId = checkId
    this.checkName = checkName
    this.getList();
  },
  methods: {
    /** 查询单列表 */
    getList() {
      this.loading = true;
      listCheck(this.queryParams).then(response => {
        this.formList = response.rows;
        this.total = response.total;
        this.loading = false;
        console.log(this.formList)
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    handleJump(data) {
      this.$router.push({
        path: '/form/answer',
        query: {
          checkRecord: encodeURI(JSON.stringify(data))
        }
      })
    },
    //关闭页面
    closePage() {
      this.$store.dispatch('tagsView/delView', this.$route)
      this.$tab.openPage("专项检查", "/form/check");
    }
  }
};
</script>

<style scoped>
.app-container {
  background-color: #edf1f2;
  padding: 10px;
  min-height: calc(100vh - 35px)
}

::v-deep.pagination-container .el-pagination {
  text-align: center;
  position: sticky;
}

::v-deep.el-form-item {
  margin-bottom: 0;
}
</style>
